package karaoke.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Collection;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import karaoke.excepcion.DAOExcepcion;
import karaoke.modelo.Local;
import karaoke.modelo.Sala;
import karaoke.negocio.GestionLocal;
import karaoke.negocio.GestionSala;

/**
 * Servlet implementation class SalaNuevoServlet
 */
@WebServlet("/SalaNuevoServlet")
public class SalaNuevoServlet extends HttpServlet {
	 GestionLocal gestorLocal = new GestionLocal();
	
	private static final long serialVersionUID = 1L;
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
        	request.setAttribute("LOCALES", gestorLocal.listar());
            RequestDispatcher rd = request.getRequestDispatcher("/Salas_nuevo.jsp");
            rd.forward(request, response);
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            out.close();
        }
    }  
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SalaNuevoServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("Mostrando el servlet SalaNuevoServlet en el doGet ");
		processRequest(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		processRequest(request, response);

		// TODO Auto-generated method stub
	}

}
